//
//  FirstTableCell.m
//  轮胎商城
//
//  Created by 张晋磊 on 2017/3/23.
//  Copyright © 2017年 张晋磊. All rights reserved.
//

#import "FirstTableCell.h"

@interface FirstTableCell ()

@property (nonatomic,copy) Myblock block;

@end

@implementation FirstTableCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
    
        CGSize size = [UIScreen mainScreen].bounds.size;
        
        for(int i=0;i<4;i++){
        
            UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
            
            bt.frame =CGRectMake(size.width/4 *i, 0, size.width/4-2, self.frame.size.height);
            bt.tag = 100+i;
//            [bt setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
//            [bt setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
//            [bt setImage:[UIImage imageNamed:@"z2"] forState:UIControlStateNormal];
            [bt setTitle:@"按钮" forState:UIControlStateNormal];
            [bt setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            
            [bt addTarget:self action:@selector(btClick:) forControlEvents:UIControlEventTouchUpInside];
            
            [self.contentView addSubview:bt];
        }
    }
    return self;
}

-(void)btClick:(UIButton *)bt{

    if(self.block){

        NSLog(@"%@",self.block(bt.tag));
    }
}

-(void)clickBtBlock:(NSString *(^)(NSInteger))block{

    if(_block != block){
    
        _block = block;
    }
}

@end
